package likouJava;

import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class 二叉树翻转 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        while (t-- > 0){
            int n = scanner.nextInt();
            int k = scanner.nextInt();
            String s = scanner.next();
            int count = 0;
            int half = k / 2;

            int[] sum = new int[n + 1];
            for (int i = 0; i <= n - k; i++) {
                int sum1 = 0, sum2 = 0;
                for (int j = 0; j < half; j++){
                    sum1 += s.charAt(i + j) - '0';
                    sum2 += s.charAt(i + j + half) - '0';
                }
                if (sum1 == sum2){
                    count++;
                }
            }
            System.out.println(count);
        }
        scanner.close();
    }


}
